package com.sgj.route;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author 沈国纪
 * @date 2020/12/17 11:55
 */
@Component
public class RouteCustomer {

    @RabbitListener(bindings = {
            @QueueBinding(
                    // 创建临时队列
                    value = @Queue,
                    // 指定的交换机和类型  ，类型默认是 direct
                    exchange = @Exchange(value = "directs", type = "direct"),
                    // 接收信息的类型
                    key = {"info", "error", "warn"}
            )
    })
    public void receive1(String message) {
        System.out.println("message1 = " + message);
    }


    @RabbitListener(bindings = {
            @QueueBinding(
                    // 创建临时队列
                    value = @Queue,
                    // 指定的交换机和类型  ，类型默认是 direct
                    exchange = @Exchange(value = "directs", type = "direct"),
                    // 接收信息的类型
                    key = {"error"}
            )
    })
    public void receive2(String message) {
        System.out.println("message2 = " + message);
    }
}
